<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取常量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionclass.getconstant.html">« ReflectionClass::getConstant</a></li>
      <li style="float: right;"><a href="reflectionclass.getconstructor.html">ReflectionClass::getConstructor »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionclass.html">ReflectionClass</a></li>
    <li>获取常量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionclass.getconstants" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::getConstants</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::getConstants</span> &mdash; <span class="dc-title">获取常量</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.getconstants-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::getConstants</strong></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">int</span><span class="type"></span></span> <code class="parameter">$filter</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   从类中获取所有已定义的常量，而不管它们的可见性如何。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.getconstants-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">filter</code></dt>

    <dd>

     <p class="para">
      可选过滤器，传入过滤所需的可见性常量。可用
      <a href="class.reflectionclassconstant.html#reflectionclassconstant.constants.modifiers" class="link">ReflectionClassConstant 常量</a>
      进行配置，默认为所有可见性常量。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.getconstants-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   常量的<span class="type"><span class="type 数组">数组</span></span>，常量名是数组的键，常量的值是数组的值。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-reflectionclass.getconstants-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       添加 <code class="parameter">filter</code> 。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.getconstants-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionclass.getconstant.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::getConstant()</a> - 获取已定义的常量</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>